<template>
	<view>
		
		<view class="head">
			<image :src="info.avatar" mode="" @tap="toPersonal" ></image>
			<view class="title">
				<view class="name">{{ info.nickname }}</view>
				<view class="tags" v-if="info.age!==null||info.heightdata!==null||info.habitation!==null" >{{ info.age!==null&&info.age?info.age+'岁':'' }}<text v-if="info.age!==null&&info.age" >|</text>{{ info.heightdata!==null&&info.heightdata?info.heightdata+'cm':'' }}<text v-if="info.heightdata!==null&&info.heightdata" >|</text>{{ info.habitation&&info.habitation!==null?info.habitation:'' }}</view>
				<view class="tags" v-else ></view>
			</view>
		</view>
		
		<view class="item" v-if="type==1" >
			<!-- <view class="item-title">
				To:
			</view> -->
			<view class="content">
				{{ info.msg }}
			</view>
		</view>
		
		
		<view class="item" v-if="type==0" >
			<!-- <view class="item-title">
				To:
			</view> -->
			<view class="content">
				我参加了{{ info.msg }}活动
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		computed: {
			...mapState(['token'])
		},
		data() {
			return {
				id:'',
				fId:'',
				type:'',
				info:{},
			};
		},
		onLoad(options) {
			console.log(options);
			if(options){
				this.id = options.id;
				this.fId = options.fromId;
				this.type = options.type;
			}
			
			//获取数据
			this.getData();
		},
		onShow() {
			
		},
		methods:{
			//前往个人详情
			toPersonal() {
				if(this.info.gender==1){
					uni.navigateTo({
						url: '/pages/recommend/personal?type=0&id=' + this.info.fromuserid
					})
				}else{
					uni.navigateTo({
						url: '/pages/recommend/personal?type=1&id=' + this.info.fromuserid
					})
				}
				
			},
			async getData() {
				try {
					let params = {
						token: this.token,
						msgId:this.id
					};
					let res = await this.$request.request.get('/api/user/msg', params)
					console.log(res);
					if (res.code == 200) {
						this.info = res.data;
					}
				} catch (err) {
					this.$request.error(err, this)
				}
			},
		}
	}
</script>

<style lang="scss">
@import 'message_subDetail.scss'
</style>
